package com.jiazhong.shixi.caichanguanli.controller;

import com.jiazhong.shixi.caichanguanli.bean.Assets;
import com.jiazhong.shixi.caichanguanli.mapper.AssetsMapper;
import com.jiazhong.shixi.caichanguanli.util.JsonResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.net.URI;
import java.util.List;
@CrossOrigin("*")
@RestController
@RequestMapping("/assets")
public class AssetsController {
    @Resource
    private AssetsMapper assetsMapper;

    @RequestMapping("/add")
    public JsonResult addAsset(Assets sc) {
        assetsMapper.add(sc);
        JsonResult result = new JsonResult(true, 200, "success", null);
        return result;
    }

    @RequestMapping("/select")
    public JsonResult getAsset(Assets sc) {
        System.out.println(sc);
        List<Assets>  list =   assetsMapper.selectByDate();
        JsonResult result = new JsonResult(true, 200, list , null);
        return result;
    }


   @RequestMapping("/delete")
    public JsonResult deleteAsset(Assets sc) {
        assetsMapper.deleteById(sc);
        JsonResult result = new JsonResult(true, 200, "success", null);
        return result;
    }

}